<?php

use yii\db\Migration;

class m171018_060908_alter_lesson_student extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%lesson_student}}', 'teacher_growth_score', $this->smallInteger(2) . ' default 0 comment \'学生对教师成长日志满意度\'');
            $this->addColumn('{{%lesson_student}}', 'headmaster_growth_score', $this->smallInteger(2) . ' default 0 comment \'学生对班主任成长日志满意度\'');
            $this->addColumn('{{%lesson_student}}', 'student_teacher_score', $this->smallInteger(2) . ' default 0 comment \'学生对教师的评分\'');
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%lesson_student}}', 'teacher_growth_score');
            $this->dropColumn('{{%lesson_student}}', 'headmaster_growth_score');
            $this->dropColumn('{{%lesson_student}}', 'student_teacher_score');
        }
    }
}
